package day14;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

//没有顺序，不能存重复的元素。首先判断hashCode,然后再判断equals方法
public class HashSetTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Set<Person> set = new HashSet<Person>();
		set.add(new Person("wangbiao",21));
		set.add(new Person("zhangsan",22));
		set.add(new Person("wangwu",23));
		set.add(new Person("zhaoliu",25));
		set.add(new Person("li",25));
		set.add(new Person("wangbiao",21));
		set.add(new Person("li",25));
		for (Iterator<Person> iterator = set.iterator(); iterator.hasNext();) {
			Person person = iterator.next();
			System.out.println(person);
			
		}
	}

}
